#define _CRT_SECURE_NO_WARNINGS
class Solution {
public:
    bool canJump(vector<int>& nums) {
        int len = 0;
        for (int i = 0; i < nums.size(); i++)
        {
            if (i <= len)
            {
                len = max(len, i + nums[i]);
                if (len >= nums.size() - 1) return true;
            }
        }
        return false;
    }
};